package com.leetcode.August;

/**
 * @Description: 141. 环形链表
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-24 16:38
 */
public class LC141环形链表 {
    public boolean hasCycle(ListNode head) {
        if(head==null) return false;
        ListNode slow = head;
        ListNode fast = head;
        while (fast!=null && fast.next!=null){
            slow=slow.next;
            fast=fast.next.next;
            if(slow==fast) return true;
        }
        return false;
    }
}
